package com.ebupt.migu.music.global.controller;

import com.ebupt.migu.music.common.auth.IDAuthUtils;
import com.ebupt.migu.music.common.entity.ResultObject;
import com.ebupt.migu.music.common.util.ReqestParamUtil;
import com.ebupt.migu.music.global.service.GlobalApproveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Author liuyangyang@ebupt.com
 * @Description
 * @Date 2021/11/23 10:04
 */
@Slf4j
@RestController
@RequestMapping("/global/approve")
public class GlobalApproveController {

    @Autowired
    private HttpServletRequest request;
    @Autowired
    private GlobalApproveService globalApproveService;
    @Autowired
    private IDAuthUtils idAuthUtils;

    /**
     * 查询全局弹窗审核人
     *
     * @return
     */
    @RequestMapping("/qryChecker")
    public ResultObject qryChecker() {
        return globalApproveService.qryChecker();
    }

    /**
     * 查询策略审批列表
     *
     * @return
     */
    @RequestMapping("/qryApproveList")
    public ResultObject qryApproveList() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        // 是否超级管理员
        params = idAuthUtils.isAdmin(params);
        return globalApproveService.qryApproveList(params);
    }

    /**
     * 活动审批
     * @return
     */
    @RequestMapping("/saveApprove")
    public ResultObject saveApprove() {
        Map<String, Object> params = ReqestParamUtil.getParamsWithUserInfo(request);
        // 是否超级管理员
        params = idAuthUtils.isAdmin(params);
        return globalApproveService.saveApprove(params);
    }

    /**
     * 查询审批历史
     *
     * @return
     */
    @RequestMapping("/qryApproveHistory")
    public ResultObject qryApproveHistory() {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return globalApproveService.qryApproveHistory(params);
    }

}
